package com.gomoku.common.exception;

/**
 * 统一错误码常量类
 * 根据业务模块分类定义错误码
 * 
 * @author gomoku
 * @version 1.0.0
 * @since 2024-01-01
 */
public class ErrorCode {

    // ==================== 通用错误码 ====================
    
    /**
     * 成功
     */
    public static final String SUCCESS = "0000";
    
    /**
     * 系统内部错误
     */
    public static final String SYSTEM_ERROR = "9999";
    
    /**
     * 参数错误
     */
    public static final String PARAM_ERROR = "1000";
    
    /**
     * 参数为空
     */
    public static final String PARAM_NULL = "1001";
    
    /**
     * 参数格式错误
     */
    public static final String PARAM_FORMAT_ERROR = "1002";
    
    /**
     * 参数长度超限
     */
    public static final String PARAM_LENGTH_ERROR = "1003";

    // ==================== 用户管理模块错误码 (2000-2999) ====================
    
    /**
     * 用户不存在
     */
    public static final String USER_NOT_FOUND = "2001";
    
    /**
     * 用户名已存在
     */
    public static final String USERNAME_EXISTS = "2002";
    
    /**
     * 用户名格式错误
     */
    public static final String USERNAME_FORMAT_ERROR = "2003";
    
    /**
     * 用户名长度错误
     */
    public static final String USERNAME_LENGTH_ERROR = "2004";
    
    /**
     * 密码格式错误
     */
    public static final String PASSWORD_FORMAT_ERROR = "2005";
    
    /**
     * 密码长度错误
     */
    public static final String PASSWORD_LENGTH_ERROR = "2006";
    
    /**
     * 用户信息更新失败
     */
    public static final String USER_UPDATE_FAILED = "2007";
    
    /**
     * 用户创建失败
     */
    public static final String USER_CREATE_FAILED = "2008";

    // ==================== 认证授权模块错误码 (3000-3999) ====================
    
    /**
     * 登录失败
     */
    public static final String LOGIN_FAILED = "3001";
    
    /**
     * 用户名或密码错误
     */
    public static final String LOGIN_CREDENTIALS_ERROR = "3002";
    
    /**
     * 用户未登录
     */
    public static final String USER_NOT_LOGIN = "3003";
    
    /**
     * Token无效
     */
    public static final String TOKEN_INVALID = "3004";
    
    /**
     * Token过期
     */
    public static final String TOKEN_EXPIRED = "3005";
    
    /**
     * 权限不足
     */
    public static final String PERMISSION_DENIED = "3006";
    
    /**
     * 会话过期
     */
    public static final String SESSION_EXPIRED = "3007";

    // ==================== 积分管理模块错误码 (4000-4999) ====================
    
    /**
     * 积分不足
     */
    public static final String SCORE_INSUFFICIENT = "4001";
    
    /**
     * 积分计算错误
     */
    public static final String SCORE_CALCULATE_ERROR = "4002";
    
    /**
     * 积分更新失败
     */
    public static final String SCORE_UPDATE_FAILED = "4003";
    
    /**
     * 积分记录创建失败
     */
    public static final String SCORE_RECORD_CREATE_FAILED = "4004";
    
    /**
     * 积分流水查询失败
     */
    public static final String SCORE_RECORD_QUERY_FAILED = "4005";

    // ==================== 匹配系统模块错误码 (5000-5999) ====================
    
    /**
     * 匹配队列已满
     */
    public static final String MATCH_QUEUE_FULL = "5001";
    
    /**
     * 用户已在匹配队列中
     */
    public static final String USER_IN_MATCH_QUEUE = "5002";
    
    /**
     * 用户不在匹配队列中
     */
    public static final String USER_NOT_IN_MATCH_QUEUE = "5003";
    
    /**
     * 匹配失败
     */
    public static final String MATCH_FAILED = "5004";
    
    /**
     * 匹配超时
     */
    public static final String MATCH_TIMEOUT = "5005";
    
    /**
     * 取消匹配失败
     */
    public static final String MATCH_CANCEL_FAILED = "5006";
    
    /**
     * 匹配算法错误
     */
    public static final String MATCH_ALGORITHM_ERROR = "5007";

    // ==================== 游戏核心模块错误码 (6000-6999) ====================
    
    /**
     * 游戏房间不存在
     */
    public static final String ROOM_NOT_FOUND = "6001";
    
    /**
     * 游戏房间已满
     */
    public static final String ROOM_FULL = "6002";
    
    /**
     * 用户不在房间中
     */
    public static final String USER_NOT_IN_ROOM = "6003";
    
    /**
     * 不是当前回合
     */
    public static final String NOT_CURRENT_TURN = "6004";
    
    /**
     * 落子位置无效
     */
    public static final String INVALID_MOVE = "6005";
    
    /**
     * 落子位置已有棋子
     */
    public static final String POSITION_OCCUPIED = "6006";
    
    /**
     * 游戏已结束
     */
    public static final String GAME_ENDED = "6007";
    
    /**
     * 游戏未开始
     */
    public static final String GAME_NOT_STARTED = "6008";
    
    /**
     * 认输失败
     */
    public static final String SURRENDER_FAILED = "6009";
    
    /**
     * 游戏状态错误
     */
    public static final String GAME_STATE_ERROR = "6010";
    
    /**
     * 棋盘状态错误
     */
    public static final String BOARD_STATE_ERROR = "6011";

    // ==================== 实时通信模块错误码 (7000-7999) ====================
    
    /**
     * WebSocket连接失败
     */
    public static final String WEBSOCKET_CONNECT_FAILED = "7001";
    
    /**
     * WebSocket连接已断开
     */
    public static final String WEBSOCKET_DISCONNECTED = "7002";
    
    /**
     * 消息发送失败
     */
    public static final String MESSAGE_SEND_FAILED = "7003";
    
    /**
     * 消息格式错误
     */
    public static final String MESSAGE_FORMAT_ERROR = "7004";
    
    /**
     * 连接状态异常
     */
    public static final String CONNECTION_STATE_ERROR = "7005";
    
    /**
     * 心跳检测失败
     */
    public static final String HEARTBEAT_FAILED = "7006";

    // ==================== 数据库操作错误码 (8000-8999) ====================
    
    /**
     * 数据库连接失败
     */
    public static final String DATABASE_CONNECT_FAILED = "8001";
    
    /**
     * 数据库操作失败
     */
    public static final String DATABASE_OPERATION_FAILED = "8002";
    
    /**
     * 数据不存在
     */
    public static final String DATA_NOT_FOUND = "8003";
    
    /**
     * 数据已存在
     */
    public static final String DATA_ALREADY_EXISTS = "8004";
    
    /**
     * 数据更新失败
     */
    public static final String DATA_UPDATE_FAILED = "8005";
    
    /**
     * 数据删除失败
     */
    public static final String DATA_DELETE_FAILED = "8006";
    
    /**
     * 事务回滚失败
     */
    public static final String TRANSACTION_ROLLBACK_FAILED = "8007";

    // ==================== Redis操作错误码 (9000-9099) ====================
    
    /**
     * Redis连接失败
     */
    public static final String REDIS_CONNECT_FAILED = "9001";
    
    /**
     * Redis操作失败
     */
    public static final String REDIS_OPERATION_FAILED = "9002";
    
    /**
     * 缓存过期
     */
    public static final String CACHE_EXPIRED = "9003";
    
    /**
     * 缓存更新失败
     */
    public static final String CACHE_UPDATE_FAILED = "9004";
    
    /**
     * 缓存删除失败
     */
    public static final String CACHE_DELETE_FAILED = "9005";

    /**
     * 私有构造方法，防止实例化
     */
    private ErrorCode() {
        throw new UnsupportedOperationException("ErrorCode class cannot be instantiated");
    }
}
